package com.sc.nft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserEcologyPointsWallet;
import com.sc.nft.entity.vo.AdminDaoEcologyPointWalletPageVO;
import com.sc.nft.entity.vo.AdminEcologyPointsUserWalletPageVO;
import com.sc.nft.entity.vo.AdminUserEcologyPointWalletPageVO;
import com.sc.nft.entity.vo.ecology.AdminEcologyPointsUserPageVO;
import com.sc.nft.entity.vo.ecology.EcologyPointWalletExpendPageVO;
import com.sc.nft.entity.vo.ecology.EcologyPointWalletPageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 用户生态积分钱包 Mapper 接口
 * </p>
 *
 * @author liGen
 * @since 2024-11-26
 */
@Mapper
public interface UserEcologyPointsWalletMapper extends BaseMapper<UserEcologyPointsWallet> {

    /**
     * 加积分
     * @param id
     * @param sum
     * @param oldAmount
     * @return
     */
    Boolean addAmount(@Param("id") Long id, @Param("sum") BigDecimal sum, @Param("oldAmount") BigDecimal oldAmount);

    /**
     * 减积分
     * @param id
     * @param sum
     * @param oldAmount
     * @return
     */
    Boolean subAmount(@Param("id") Long id, @Param("sum") BigDecimal sum, @Param("oldAmount") BigDecimal oldAmount);

    /**
     * 用户积分列表
     *
     * @param page
     * @param userCreatorId
     * @return
     */
    IPage<EcologyPointWalletPageVO> userPage(Page page, @Param("userCreatorId") Long userCreatorId, @Param("userId") Long userId);

    /**
     * 积分钱包支出记录
     *
     * @param objectPage
     * @param userPointsWalletId
     * @param userId
     * @return
     */
    IPage<EcologyPointWalletExpendPageVO> userEcologyPointsExpend(Page page, @Param("userPointsWalletId") Long userPointsWalletId, @Param("userId") Long userId);


    Page<AdminEcologyPointsUserWalletPageVO> getUserPage(Page page, @Param("userTel") String userTel);


    IPage<AdminUserEcologyPointWalletPageVO> adminUserPointWalletPage(Page page, @Param("userId") Long userId);


    IPage<AdminDaoEcologyPointWalletPageVO> adminDaoPointWalletPage(Page page, @Param("userCreatorId") Long userCreatorId);

    BigDecimal getUserBalanceAmount(@Param("pointsId") Long pointsId);


    /**
     * 添加金额并且扣除限额
     * @param userId
     * @param amount
     * @return
     */
    Boolean addEcologyPoints(Long userId, BigDecimal amount);



}
